package com.oschat.controller;

import com.oschat.annotation.GlobalInterceptor;
import com.oschat.entity.constants.Constants;
import com.oschat.entity.dto.TokenUserInfoDto;
import com.oschat.entity.po.UserInfo;
import com.oschat.entity.query.UserInfoQuery;
import com.oschat.entity.vo.PaginationResultVO;
import com.oschat.entity.vo.ResponseVO;
import com.oschat.entity.vo.UserInfoVO;
import com.oschat.service.UserInfoService;
import com.oschat.utils.CopyTools;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.IOException;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2025/7/30 15:37
 */
@RestController("adminUserInfoController")
@RequestMapping("/admin")
public class AdminUserInfoController extends ABaseController {

    @Resource
    private UserInfoService userInfoService;

    /**
     * @description: 管理员查看所有用户
     * @author Administrator
     * @date 2025/8/14 19:18
     * @version 1.0
     */
    @RequestMapping("/loadUser")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO loadUser(UserInfoQuery userInfoQuery) {
        userInfoQuery.setOrderBy("create_time desc");
        PaginationResultVO result = userInfoService.findListByPage(userInfoQuery);
        return getSuccessResponseVO(result);
    }
    /**
     * @description: 管理员跟新用户状态
     * @author Administrator
     * @date 2025/8/14 19:19
     * @version 1.0
     */
    @RequestMapping("/updateUserStatus")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO updateUserStatus(@NotNull Integer status, @NotEmpty String userId) {
        userInfoService.updateUserStatus(status, userId);
        return getSuccessResponseVO(null);
    }

    /**
     * @description: 管理员强制用户下线
     * @author Administrator
     * @date 2025/8/14 19:19
     * @version 1.0
     */
    @RequestMapping("/forceOffLine")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO forceOffLine(@NotEmpty String userId) {
        userInfoService.forceOffLine(userId);
        return getSuccessResponseVO(null);
    }
}
